package com.xique.api.api.factory;

import com.xique.api.api.RemoteAccessTokenService;
import com.xique.common.core.domain.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author shd
 * @create 2022/2/23 20:16
 */
@Component
public class RemoteAccessTokenFallbackFactory implements FallbackFactory<RemoteAccessTokenService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteAccessTokenFallbackFactory.class);

    @Override
    public RemoteAccessTokenService create(Throwable throwable) {
        log.error("系统用户服务调用失败:{}", throwable.getMessage());
        return (appId, appSecret) -> R.fail("获取accessToken值失败:" + throwable.getMessage());
    }
}
